﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBControl;
using System.Data.SqlClient;

namespace SellerProject
{
    public partial class sellMain : TopBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //string userNick;
            if (!IsPostBack)
            {
                getTotalCount();
                bindRepeater();
            }
        }
        private void bindRepeater()
        {
            SqlDbHelper sdh = new SqlDbHelper();
            string sqlwhere = " where [Status]=0 and [bsc]=0 or [Status]=0 and [bsc]<>0 and [rsn] <> '" + Session["usNick"].ToString() + "'";
            SqlParameter p1 = new SqlParameter("@tablename", "GetDateByUser");//视图名或表名
            SqlParameter p2 = new SqlParameter("@pagerow", this.repPager.PageSize);         //每页显示记录数 
            SqlParameter p3 = new SqlParameter("@pagenow", this.repPager.CurrentPageIndex); //当前显示第几页 
            SqlParameter p4 = new SqlParameter("@ordercol", "Starttime");//排序字段
            SqlParameter p5 = new SqlParameter("@order", 1);//排序顺序，0升序，1降序
            SqlParameter p6 = new SqlParameter("@where", sqlwhere);
            SqlParameter[] paras = new SqlParameter[] { p1, p2, p3, p4, p5, p6 };
            this.binfoRepeater.DataSource = sdh.ExecuteDataTable("sp_page", System.Data.CommandType.StoredProcedure, null, paras);
            binfoRepeater.DataBind();
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = sender as LinkButton;
            GridViewRow gvr = lbtn.Parent.Parent as GridViewRow;
            Response.Redirect("sellGoodsel.aspx?BinfoID="+ gvr.Cells[1].Text +",binfoName=" + gvr.Cells[2].Text );
        }

        protected void repPager_PageChanged(object sender, EventArgs e)
        {
            bindRepeater();
            ScriptManager.RegisterStartupScript(repPager, this.GetType(), "resizeimg", "<script>ResizeImg();</script>", false);
        }
        private void getTotalCount()
        {
            SqlDbHelper sdh = new SqlDbHelper();
            string sqlcount = "SELECT COUNT(*) FROM BuyersinfoR WHERE Status = 0";
            this.repPager.RecordCount = int.Parse(sdh.ExecuteScalar(sqlcount).ToString());
        }
    }
}